function setAjax(){
    $.ajaxSetup({cache: false,xhrFields:{withCredentials : true},crossDomain : true});
}

/**
 * 初始化顶部导航请求
 */
function getTopNav() {
    var requestBPlateUrl = requestService.preUrl + requestService.GET_BIG_PALTE,
        field = {
            "id": "topic_id",
            "name": "topic_name"
        };
    setLoad("#topNav", "topNav");
    $.getJSON(requestBPlateUrl, function (res) {
        var bigData = res["data"];
        var topNavHtml = '<li class="cms-head-logo"><img src="images/logo.png"></li>'
            + '<li><a href="/">首页</a></li>';
        for (var key in bigData) {
            topNavHtml += '<li><a href="PostList.html?plate=' + bigData[key][field["id"]] + '">' + bigData[key][field["name"]] + '</a></li>';
        }
        topNavHtml += '<li class="cms-head-search">'
            + '<input type="text" class="form-control search-input" placeholder="搜索关键字">'
            + '<i class="layui-icon layui-icon-search btn-search"></i>'
            + '</li>';
        var checkLogin = getCookie("Login_Now_User");
        if (checkLogin != null) {
            topNavHtml += '<li><a href="Console.html">个人中心</a></li>';
        } else {
            topNavHtml += '<li><a href="Login.html">登录</a>/<a href="Register.html">注册</a></li>';
        }
        $("#topNav").html(topNavHtml);
        delLoad("topNav");
    });
}



/**
 * 初始化文章请求
 * @param {*} pageId //文章标题
 */
function getArticle(pageId) {
    $.ajaxSetup({cache: false,xhrFields:{withCredentials : true},crossDomain : true});
    //setLoad(".cms-post-left.article");//填充遮罩
    setLoad(".article-content", "article-content");
    //var requestBPlateUrl = requestConfig.preUrl + requestConfig.GET_ONE_POST, //请求URL
    var requestBPlateUrl = requestService.preUrl + requestService.GET_ONE_POST, //请求URL
        requestParam = { "article_id": pageId }, //请求参数
        //JSON参数名
        field = {
            "bigplate": "",  //大板块名称
            "smallplate": "togic_name", //小板块名称
            "smallplateId": "togic_id", //小板块编号
            "topic_name": "togic_name", //小版块名称
            "title": "title",  //标题
            "read_count": "read_count",  //浏览量
            "username": "username",  //发帖人名称
            "create_time": "create_time", //发布时间
            "content": "content",  //文章内容
            "has_tag": "has_tag"  //标签集合
        };
    $.getJSON(requestBPlateUrl, requestParam, function (res) {
        if (res["code"] == 0) {
            var articleData = res["data"];

            //位置
            var cms_location = "";
            cms_location += '<a href="index.html">首页</a>>';
            cms_location += '<a href="index.html">' + articleData[field["bigplate"]] + '</a>>';
            cms_location += '<a href="PostList.html?plate=' + articleData[field["smallplateId"]] + '">' + articleData[field["bigplate"]] + '</a>>';
            cms_location += '<a href="#">' + articleData[field["title"]] + '</a>>';

            //文章内容
            $("#article_plate").html(articleData[field["topic_name"]]);
            $("#article_title").html(articleData[field["title"]]);
            $("#article_read_count").html(articleData[field["read_count"]]);
            $("#article_author").html(articleData[field["username"]]);
            $("#article_time").html(articleData[field["create_time"]]);
            $("#article_content").html(articleData[field["content"]]);

            //标签
            
            var tag = JSON.parse(articleData[field["has_tag"]]), tagHtml = "";
            Log(articleData[field["has_tag"]]);
            for (var key in tag) {
                tagHtml += '<a href="" tagid="' + key + '">' + tag[key] + '</a>,';
            }
            $("#tag").html(tagHtml);
        } else {
            alert("文章不存在");
            history.go(-1);
        }
        delLoad("article-content");//移除遮罩 
    });

}

function getLocation(){
    var bplate = getQueryString("bplate"),
        splate = getQueryString("plate"),
        article_id = getQueryString("page")
        ,htmlData = '<a href="">首页</a>>',
        requestParam = {},
        requestBPlateUrl = requestService.preUrl + requestService.GET_LOCATION;
        if(bplate != null) requestParam.bplate = bplate;
        if(splate != null) requestParam.plate = splate;
        if(article_id != null) requestParam.page = article_id;

        $.ajaxSetup({ async: false });
        $.get(requestBPlateUrl,requestParam,function(res){
               Log(res);
                $("#cms_location").html(res);
        });
        
}


/**
 * 获取评论列表
 * @param {*} pageId 
 */
function getComment(pageId) {
    setAjax();
    //setLoad("#article_comment", "article_comment");//填充遮罩
    var requestBPlateUrl = requestConfig.preUrl + requestConfig.GET_COMMENT_BY_ARTICLE, //请求URL
        childrenUrl = requestConfig.preUrl + requestConfig.GET_COMMENT_BY_BIGCOMMENT,
        //请求参数
        requestParam = { "article_id": pageId };
    //JSON参数名
    field = {
        "commentId": "comment_id",
        "username": "username",
        "headimg": "head_img",
        "userId": "user_id",
        "comment_conent": "content",
        "time": "create_time",
        "father_id": "father_id",
        "support_count": "support_count",
        "oppos_count": "oppos_count",
        "reply_name": "username",
        "replay_id": "",
        "create_time": "create_time"
    };
    Log(requestBPlateUrl);
    $.getJSON(requestBPlateUrl, requestParam, function (res) {
        Log(res);
        if (res["code"] == 0) {
            var commentData = res["data"],
                htmlData = '';
            for (var key in commentData) {
                htmlData += '<div class="article-comment-item panel">'
                    + '<div class="article-comment-user">'
                    + '<img src="' + commentData[key][field["headimg"]] + '" alt="">'
                    + '<span class="comment-username"><i class="layui-icon layui-icon-username"></i>' + commentData[key][field["username"]] + '</span>'
                    + '<span class="comment-time">最后回帖于 ' + commentData[key][field["create_time"]] + '</span>'
                    + '</div>'
                    + '<div class="article-comment-content">' + commentData[s][field["comment_conent"]] + '</div>'
                    + '<span class="comment-order">#' + (key + 1) + '</span>';
                    requestParam.father_id = commentData[s][field["commentId"]];
                //子评论
                $.getJSON(childrenUrl,requestParam, function (son) {
                    if (son["code"] == 0) {
                        var sonData = son["data"];
                        if (sonData.lenght > 0) {
                            htmlData += '<div class="comment-reply-panel">';
                        } else {
                            htmlData += '<div class="comment-reply-panel notreply">';
                        }
                        for (var s in sonData) {
                            htmlData += '<div class="reply-item">'
                                + '<span class="reply-user">' + sonData[s][field["username"]] + '回复：</span>'
                                + '<span class="reply-content">' + sonData[s][field["comment_conent"]] + '</span>'
                                + '<span class="reply-time">' + sonData[s][field["create_time"]] + '</span>'
                                + '</div>';
                        }
                        htmlData += "</div>";
                    }
                });

                //操作
                htmlData += '<div class="article-comment-action">'
                    + '<a class="comment-reply" commentId="' + commentData[key][field["commentId"]] + '" href="">回复</a>'
                    + '<a class="comment-zan" commentId="' + commentData[key][field["commentId"]] + '" href="">点赞</a>'
                    + '<a class="comment-bag" commentId="' + commentData[key][field["commentId"]] + '" href="">差评</a>'
                    + '</div></div>';
            }
            //Log(htmlData);
            $("#article_comment").html(htmlData);
        }
       // delLoad("article_comment");//移除遮罩
    });

}



/**
 * 获取最新帖子请求
 */
function getNewPost() {
    setAjax();
   // setLoad("#new_article", "new_article");//填充遮罩
    var requestBPlateUrl = requestConfig.preUrl + requestConfig.GET_NEW_POST, //请求URL
        //请求参数
        requestParam = {},
        //JSON参数名
        field = {
            postId: "article_id",
            postName: "title",
            postTime: "create_time",
            userName: "username"
        };
        Log(requestBPlateUrl);
    $.getJSON(requestBPlateUrl, requestParam, function (res) {
        if (res["code"] == 0) {
            var newPost = res["data"],
                htmlData = '', num = 1;
            for (var key in newPost) {
                htmlData += '<div class="banner-post-item">'
                    + '<a class="item-' + num + '" postid="' + newPost[key][field.postId] + '" href="Article.html?page=' + newPost[key][field.postId] + '">'+ num + "、" + newPost[key][field.postName] +'</a>'
                    + '<span class="item-right">' + newPost[key][field.userName] + '/' + getDate(newPost[key][field.postTime]) + '</span>'
                    + '</div>';
                num++;
            }
            $("#new_article").html(htmlData);
        }
        //delLoad("new_article");//移除遮罩
    });
}


/**
 * 获取火热帖子请求
 */
function getHotPost() {
    setAjax();
    setLoad("#hot_post", "hot_post");//填充遮罩
    var requestBPlateUrl = requestConfig.preUrl + requestConfig.GET_HOT_POST, //请求URL
        //请求参数
        requestParam = {},
        //JSON参数名
        field = {
            postId: "",
            postName: "",
            postTime: "",
            userName: "",
            postImg: "",
            plateName: "",
            postInfo: "",
        };
    $.getJSON(requestBPlateUrl, requestParam, function (res) {
        if (res["code"] == 0) {
            var hotPost = res["data"],
                htmlData = '';
            for (var key in hotPost) {
                htmlData += '<div class="cms-post-item">'
                    + '<a href="Article.html?page=' + hotPost[field.postId] + '">'
                    + '<div class="post-item-img">'
                    + '<img src="' + hotPost[field.postImg] + '" alt="">'
                    + '</div>'
                    + '<div class="post-item-data">'
                    + '<div class="post-item-data-head">'
                    + '<div class="post-item-title">[' + hotPost[field.plateName] + ']' + hotPost[field.postName] + '</div>'
                    + '</div>'
                    + '<div class="post-item-info">'
                    + hotPost[field.postInfo]
                    + '</div>'
                    + '<div class="post-item-author">@' + hotPost[field.userName] + '</div>'
                    + '</div>'
                    + '</a>'
                    + '</div>';
            }
            $("#hot_post").html(htmlData);
        }
        delLoad("hot_post");//移除遮罩
    });
}

/**
 * 获取模块列表请求
 */
function getPlate() {
    //setLoad("#plate_list", "plate_list");//填充遮罩
    var requestBPlateUrl = requestService.preUrl + requestService.GET_BIG_PALTE, //请求URL
        childrenUrl = requestService.preUrl + requestService.GET_SMALL_BY_BIG, //子模块请求参数
        //请求参数
        requestParam = {},
        //JSON参数名
        field = {
            plateId: "topic_id",
            plateName: "topic_name",
            plateImg: "topic_img",
            platePostCount: ""
        };
    $.getJSON(requestBPlateUrl, requestParam, function (res) {
        if (res["code"] == 0) {
            var bigPlate = res["data"], htmlData = '';

            for (var big in bigPlate) {
                htmlData = '<div class="bigplate-item-panel">'
                    + '<div class="model-titile-panel"><span class="model-title">' + bigPlate[big][field.plateName] + '</span></div>'
                    + '<div class="plate-list">';
                requestParam = { father_id: bigPlate[big][field.plateId] };
                $.ajaxSetup({ async: false });
                $.getJSON(childrenUrl, requestParam, function (smallres) {
                    //Log(requestParam);
                    if (smallres["code"] == 0) {
                        var smallData = smallres["data"];

                        for (var small in smallData) {
                            htmlData += '<a href="PostList.html?plate=' + smallData[small][field.plateId] + '" class="plate-item">'
                                + '<div class="plate-item-left">'
                                + '<img src="' + smallData[small][field.plateImg] + '" alt="">'
                                + '</div>'
                                + '<div class="plate-item-right">'
                                + '<div class="plate-item-name">' + smallData[small][field.plateName] + '</div>	'
                                + '<div class="plate-item-postnum">帖子数：568</div>'
                                + '<div class="plate-item-post-lesttime">最后发表于 2019-07-09 09:38:08</div>'
                                + '</div>'
                                + '</a>';
                        }
                    }
                });
                htmlData += '</div></div>';
                $("#plate_list").append(htmlData);
            }



        }
        //delLoad("plate_list");//移除遮罩
    });
}
function getSeachResult(key){
    setLoad("#post_list", "post_list");//填充遮罩
    var requestBPlateUrl = requestConfig.preUrl + requestConfig.GET_SEARCH_RESULT, //请求URL
   // var requestBPlateUrl = requestService.preUrl + requestService.GET_POST_BY_PLATE, //请求URL
        //请求参数
        requestParam = {
            keyword : key
        },
        //JSON参数名
        field = {
            postId: "article_id",  //帖子编号
            postName: "title", //帖子标题
            postTime: "create_time",
            postRead: "read_count",
            postComent: "commnet_count",
            postSupport: "read_count",
            postPlate: "topic_name",
            postIsTop: "istop",
            postIsWonderful: "isgood",
            userImg: "head_img",
            userName: "username",
            isTopValue: "is",
            isWonderfulValue: "is"
        };
    $.getJSON(requestBPlateUrl, requestParam, function (res) {
        if (res["code"] == 0) {
            var post = res["data"];
            var htmlData = '';
            for (var key in post) {
                var istop = '', iswonder = '';
                //判断该帖是否顶置
                post[key][field.postIsTop] == field.isTopValue ? istop = '<i class="layui-icon layui-icon-top"></i>' : istop = '';
                //判断该帖是否加精
                post[key][field.postIsWonderful] == field.isWonderfulValue ? iswonder = '<i class="layui-icon layui-icon-fire"></i>' : iswonder = '';
                htmlData += '<div class="post_item">'
                    + '<a href="Article.html?page=' + post[key][field.postId] + '">'
                    + '<div class="post_item_left">'
                    + '<div class="post_item_authorimg">'
                    + '<img src="' + post[key][field.userImg] + '" alt="">'
                    + '</div>'
                    + '<div class="post_item_data">'
                    + '<div class="post_data_head top">'
                    + '<span class="post_data_plate">[' + post[key][field.postPlate] + ']</span>'
                    + '<span class="post_data_title">' + post[key][field.postName] + '</span>'
                    + istop
                    + iswonder
                    + '</div>'
                    + '<div class="post_data_bottom">'
                    + '<span class="post_data_author">楼主：' + post[key][field.userName] + '</span>'
                    + '<span class="post_data_tiem">' + post[key][field.postTime] + '</span>'
                    + '</div>'
                    + '</div>'
                    + '</div>'
                    + '</a>'
                    + '<div class="post_item-right">'
                    + '<span class="post_data_readnum"><i class="layui-icon layui-icon-fire"></i>' + post[key][field.postRead] + '</span>'
                    + '<span class="post_data_readnum"><i class="layui-icon layui-icon-reply-fill"></i>' + post[key][field.postComent] + '</span>'
                    + '<span class="post_data_readnum"><i class="layui-icon layui-icon-praise"></i>' + post[key][field.postSupport] + '</span>'
                    + '</div>'
                    + '</div>';
            }

            $("#post_list").html(htmlData);
        }

        delLoad("post_list");//移除遮罩
    });
}




/**
 * 获取某板块下所有帖子
 */
function getPostList(plateId) {
    setLoad("#post_list", "post_list");//填充遮罩
    //var requestBPlateUrl = requestConfig.preUrl + requestConfig.GET_ONE_POST, //请求URL
    var requestBPlateUrl = requestService.preUrl + requestService.GET_POST_BY_PLATE, //请求URL
        //请求参数
        requestParam = {
            topic_id : plateId
        },
        //JSON参数名
        field = {
            postId: "article_id",  //帖子编号
            postName: "title", //帖子标题
            postTime: "create_time",
            postRead: "read_count",
            postComent: "commnet_count",
            postSupport: "read_count",
            postPlate: "topic_name",
            postIsTop: "istop",
            postIsWonderful: "isgood",
            userImg: "head_img",
            userName: "username",
            isTopValue: "is",
            isWonderfulValue: "is"
        };
    $.getJSON(requestBPlateUrl, requestParam, function (res) {
        if (res["code"] == 0) {
            var post = res["data"];
            var htmlData = '';
            for (var key in post) {
                var istop = '', iswonder = '';
                //判断该帖是否顶置
                
                post[key][field.postIsTop] == field.isTopValue ? istop = '<i class="layui-icon layui-icon-top"></i>' : istop = '';
                //判断该帖是否加精
               
                post[key][field.postIsWonderful] == field.isWonderfulValue ? iswonder = '<i class="layui-icon layui-icon-fire"></i>' : iswonder = '';
                htmlData += '<div class="post_item">'
                    + '<a href="Article.html?plate=' + plateId + '&page=' + post[key][field.postId] + '">'
                    + '<div class="post_item_left">'
                    + '<div class="post_item_authorimg">'
                    + '<img src="' + post[key][field.userImg] + '" alt="">'
                    + '</div>'
                    + '<div class="post_item_data">'
                    + '<div class="post_data_head top">'
                    + '<span class="post_data_plate">[' + post[key][field.postPlate] + ']</span>'
                    + '<span class="post_data_title">' + post[key][field.postName] + '</span>'
                    + istop
                    + iswonder
                    + '</div>'
                    + '<div class="post_data_bottom">'
                    + '<span class="post_data_author">楼主：' + post[key][field.userName] + '</span>'
                    + '<span class="post_data_tiem">' + post[key][field.postTime] + '</span>'
                    + '</div>'
                    + '</div>'
                    + '</div>'
                    + '</a>'
                    + '<div class="post_item-right">'
                    + '<span class="post_data_readnum"><i class="layui-icon layui-icon-fire"></i>' + post[key][field.postRead] + '</span>'
                    + '<span class="post_data_readnum"><i class="layui-icon layui-icon-reply-fill"></i>' + post[key][field.postComent] + '</span>'
                    + '<span class="post_data_readnum"><i class="layui-icon layui-icon-praise"></i>' + post[key][field.postSupport] + '</span>'
                    + '</div>'
                    + '</div>';
            }

            $("#post_list").html(htmlData);
        }

        delLoad("post_list");//移除遮罩
    });
}




/**
 * 选择框获取一级板块
 */
function getMasterPlate() {
    var requestBPlateUrl = requestService.preUrl + requestService.GET_BIG_PALTE,
        field = {
            plateId: "topic_id",
            plateName: "topic_name"
        };
    $.getJSON(requestBPlateUrl, function (res) {
        if (res.code == 0) {
            var htmlData = '<option value="-1">未选择</option>';
            for (var key in res.data) {
                htmlData += '<option value="' + res.data[key][field.plateId] + '">' + res.data[key][field.plateName] + '</option>';
            }
            $("select[name='rebigplate']").html(htmlData);
            layui.use('form', function () {
                var form = layui.form;//高版本建议把括号去掉，有的低版本，需要加()
                form.render();
            });
        } else {
            layer.msg(res.msg);
        }
    });
}

/**
 * 获取二级板块
 */
function getPlateByMaster(topic_id) {
    var requestBPlateUrl = requestService.preUrl + requestService.GET_SMALL_BY_BIG,
        field = {
            plateId: "topic_id",
            plateName: "topic_name"
        },
        requestParam = {
            topic_id: topic_id
        };
    $.getJSON(requestBPlateUrl, requestParam, function (res) {
        if (res.code == 0) {
            var htmlData = '<option value="-1">未选择</option>';
            for (var key in res.data) {
                htmlData += '<option value="' + res.data[key][field.plateId] + '">' + res.data[key][field.plateName] + '</option>';
            }
            $("select[name='resmallplate']").html(htmlData);
            layui.use('form', function () {
                var form = layui.form;//高版本建议把括号去掉，有的低版本，需要加()
                form.render();
            });
        } else {
            layer.msg(res.msg);
        }
    });
}


/**
 * 添加标签
 * @param {*} tag_name 
 */
function addTag(tag_name) {
    var requestUrl = requestService.preUrl + requestService.ADD_TAG,
        field = {
            tagId: "tag_id",
            tagName: "tag_name"
        },
        requestParam = {
            tag_name: tag_name,
            user_id: getNowUserId()
        };
    $.getJSON(requestUrl, requestParam, function (res) {
        if (res.code == 0) {
            var tag = res.data[0];
            //Log("tag",tag);
            //Log("tag[field.tagId]",tag[field.tagId]);
            var htmlData = '<span value="' + tag[field.tagId] + '" class="tag-item tag-item-' + tag[field.tagId] + '">' + tag[field.tagName] + '<i class="layui-icon layui-icon-close"></i></span>';
            Log("htmlData", htmlData);
            if ($(".tag-item-" + tag[field.tagId]).length == 0) {
                Log(htmlData);
                $("#tagpanle").append(htmlData);
                tagTotal();
            }
        } else {
            layer.msg(res.msg);
        }
    });
};

/**
 * 发布文章
 * @param {*} postname 
 * @param {*} bplate 
 * @param {*} splate 
 * @param {*} content 
 * @param {*} tagJson 
 */
function releaseArticle(postname, bplate, splate, content, tagJson) {
    setAjax();
    var requestUrl = requestConfig.preUrl + requestConfig.ADD_POST,
        requestParam = {
            topic_id: splate,
            title: postname,
            content: content,
            has_tag: tagJson
        };
    
    Log(requestUrl);
    $.get(requestUrl,requestParam, function (res) {
        Log(res);
        if (res.code == 0) {
            layer.msg("发布成功");

        } else {
            layer.msg(res.msg);
        }
    });
}

function articleDel(id) {
    setAjax();
    var url = requestConfig.preUrl + requestConfig.DELETE_POST;
    $.getJSON(url, { article_id: id }, function (res) {
        if (res["code"] == 1) {
            layer.msg('删除成功', { time: 1000, maxWidth: 160 });
        } else {
            layer.msg('删除失败', { time: 1000, maxWidth: 160 });
        }
    });
    obj.del();/*提问框清楚*/
    layer.close(index);/*删除本例*/
}
/**
 * 单个字段修改用户信息
 * @param {*} postId 
 * @param {*} field 
 * @param {*} value 
 */

function changePost(postId, field, value) {
    Log(postId);
    var requestUrl = requestService.preUrl + requestService.UPDATE_POST,
        requestParm = {
            id: postId,
            field: field,
            value: value
        }, res = false;
    $.getJSON(requestUrl, requestParm, function (res) {
        if (res["code"] == 0) {
            layer.msg("修改成功");
        } else {
            layer.msg("修改失败");
        }
    });
    return res;
}

/**
 * 单个字段修改用户信息
 * @param {*} userId 
 * @param {*} field 
 * @param {*} value 
 */
function changeUser(userId, field, value) {
    var requestUrl = requestService.preUrl + requestService.UPDATE_USER,
        requestParm = {
            id: userId,
            field: field,
            value: value
        }, res = false;
    $.getJSON(requestUrl, requestParm, function (res) {
        if (res["code"] == 0) {
            layer.msg("修改成功");
        } else {
            layer.msg("修改失败");
        }
    });
    return res;
}


/**
 * 获取当前登录用户属性
 */
function getNowUserId() {
    var res = "", field = "user_id", tb_field = {
        id: "user_id",
        power: "power"
    };
    
    if ($.cookie('Login_Now_User') != null) {
        //Log($.cookie('Login_Now_User'));
        if (arguments.length = 1) {
            field = tb_field[arguments[0]];
            if (field == null) field = "user_id";
        }
        var data = JSON.parse($.cookie('Login_Now_User'));
        res = data[field];
    }
    return res;
}


/**
 * 检测登录
 */
function checkIsLogin() {
    var history = "";
    if (arguments.length == 1) history = arguments[0];
    if (getNowUserId() == "") {
        alert("您未登录，请登陆");
        location.href = "Login.html?history=" + history;
    }
}


/**
 * 初始化控制台左侧导航
 */
function setConsoleLeftNav() {
    var power = getNowUserId("power"), htmlData = '';

    var htmlDataByAdmin = '<li class="layui-nav-item layui-nav-itemed">'
        + '<a href="javascript:;">'
        + '<i class="layui-icon layui-icon-username"></i>'
        + '<cite>用户管理</cite>'
        + '<span class="layui-nav-more"></span>'
        + '</a>'
        + '<dl class="layui-nav-child">'
        + '<dd><a class="ts-tab-active" tbkey="AllUser" href="javascript:;">全部用户</a></dd>'
        + '<dd><a class="ts-tab-active" tbkey="AddUser" href="javascript:;">添加用户</a></dd>'
        + '<dd><a class="ts-tab-active" tbkey="UserScore" href="javascript:;">用户积分</a></dd>'
        + '</dl>'
        + '</li>'
        + '<li class="layui-nav-item layui-nav-itemed">'
        + '<a href="javascript:;">'
        + '<i class="layui-icon layui-icon-username"></i>'
        + '<cite>板块管理</cite>'
        + '<span class="layui-nav-more"></span>'
        + '</a>'
        + '<dl class="layui-nav-child">'
        + '<dd><a class="ts-tab-active" tbkey="BPlate" href="javascript:;">大板块</a></dd>'
        + '<dd><a class="ts-tab-active" tbkey="SPlate" href="javascript:;">小板块</a></dd>'
        + '</dl>'
        + '</li>';
    var htmlDataPlateBySelf = '<li class="layui-nav-item layui-nav-itemed">'
        + '<a href="javascript:;">'
        + '<i class="layui-icon layui-icon-username"></i>'
        + '<cite>板块管理</cite>'
        + '<span class="layui-nav-more"></span>'
        + '</a>'
        + '<dl class="layui-nav-child">'
        + '<dd><a class="ts-tab-active" tbkey="MyPlate" href="javascript:;">我的板块</a></dd>'
        + '</dl>'
        + '</li>';
    var htmlDataByPlate = '<li class="layui-nav-item layui-nav-itemed">'
        + '<a href="javascript:;">'
        + '<i class="layui-icon layui-icon-list"></i>'
        + '<cite>帖子管理</cite>'
        + '<span class="layui-nav-more"></span>'
        + '</a>'
        + '<dl class="layui-nav-child">'
        + '<dd><a class="ts-tab-active" tbkey="AllPost" href="javascript:;">全部帖子</a></dd>'
        + '<dd><a class="ts-tab-active" tbkey="MyPost" href="javascript:;">我的帖子</a></dd>'
        + '<dd><a class="ts-tab-active" tbkey="PostExamine" href="javascript:;">帖子审核</a></dd>'
        + '<dd><a class="ts-tab-active" tbkey="ReleasePost" href="javascript:;">发布帖子</a></dd>'
        + '</dl>'
        + '</li>'
    var htmlDataMemberPost = '<li class="layui-nav-item layui-nav-itemed">'
        + '<a href="javascript:;">'
        + '<i class="layui-icon layui-icon-list"></i>'
        + '<cite>帖子管理</cite>'
        + '<span class="layui-nav-more"></span>'
        + '</a>'
        + '<dl class="layui-nav-child">'
        + '<dd><a class="ts-tab-active" tbkey="MyPost" href="javascript:;">我的帖子</a></dd>'
        + '<dd><a class="ts-tab-active" tbkey="ReleasePost" href="javascript:;">发布帖子</a></dd>'
        + '</dl>'
        + '</li>';
    var htmlDataByAdminPower = '<li class="layui-nav-item">'
        + '<a class="ts-tab-active" tbkey="AuthAdmin" href="javascript:;"><i class="layui-icon layui-icon-password"></i>'
        + '<cite>权限管理</cite>'
        + '</a>'
        + '</li>';
    var htmlDataMemberComment = '<li class="layui-nav-item">'
        + '<a class="ts-tab-active" tbkey="CommentAdmin" href="javascript:;"><i class="layui-icon layui-icon-reply-fill"></i>'
        + '<cite>我的评论</cite>'
        + '</a>'
        + '</li>'
        +'<li class="layui-nav-item">'
        + '<a class="ts-tab-active" tbkey="MyCollect" href="javascript:;"><i class="layui-icon layui-icon-reply-fill"></i>'
        + '<cite>我的收藏</cite>'
        + '</a>'
        + '</li>';

    var htmlDataByAdminLog = '<li class="layui-nav-item">'
        + '<a class="ts-tab-active" tbkey="LogAdmin" href="javascript:;"><i class="layui-icon layui-icon-table"></i>'
        + '<cite>系统日志</cite>'
        + '</a>'
        + '</li>';
    var htmlDataMemberMyData = '<li class="layui-nav-item">'
        + '<a class="ts-tab-active" tbkey="MyData" href="javascript:;">'
        + '<i class="layui-icon layui-icon-username"></i>'
        + '<cite>个人信息</cite>'
        + '</a>'
        + '</li>'
        + '<li class="layui-nav-item">'
        + '<a id="layout" href="javascript:;">'
        + '<cite>登出账户</cite>'
        + '</a>'
        + '</li>';
    if (power == "-5") {
        htmlData += htmlDataByAdmin + htmlDataByPlate + htmlDataByAdminPower + htmlDataMemberComment + htmlDataByAdminLog + htmlDataMemberMyData;
    } else if (power == "-10") {
        htmlData += htmlDataMemberPost + htmlDataMemberComment + htmlDataMemberMyData;

    } else if (power > 0) {
        htmlData += htmlDataPlateBySelf + htmlDataMemberPost + htmlDataMemberComment + htmlDataMemberMyData;
    }
    $("#nav-left").html(htmlData);
    //Log(htmlData);
}

function addCollect(article_id){
    var requestUrl = requestConfig.preUrl + requestConfig.ADD_COLLECT, //请求URL
        //请求参数
        requestParam = {
            article_id: article_id
        };
        $.getJSON(requestUrl,requestParam,function(res){
            if (res.code == 0) {
                msg("收藏成功");
            } else {
                msg(res.msg);
            }
        });
}

function addGoodNum(article_id){
    var requestUrl = requestService.preUrl + requestService.ADD_GOOD, //请求URL
        //请求参数
        requestParam = {
            article_id: article_id
        };
        $.getJSON(requestUrl,requestParam,function(res){
            if (res.code == 0) {
                msg("点赞成功");
            } else {
                msg(res.msg);
            }
        });
}

function replayComment(article_id, father_id,content){

}
/**
 * 添加评论
 * @param {*} article_id 
 * @param {*} content 
 */
function addComment(article_id, content) {
    setAjax();
    var requestUrl = requestConfig.preUrl + requestConfig.ADD_COMMENT_F, //请求URL
        //请求参数
        requestParam = {
            article_id: article_id,
            content: content,
        },
        //JSON参数名
        field = {
            article_id: article_id,
            content: content
        };
        Log(requestParam);
    $.getJSON(requestUrl, requestParam, function (res) {
        if (res.code == 0) {
            msg("评论成功");
        } else {
            msg(res.msg);
        }
    });
}
/**
 * 请求模板
 */
function requestTemp() {
    setLoad("");//填充遮罩
    var requestUrl = requestConfig.preUrl + requestConfig.GET_ONE_POST, //请求URL
        //请求参数
        requestParam = {},
        //JSON参数名
        field = {};
    $.getJSON(requestUrl, requestParam, function (res) {


        delLoad();//移除遮罩
    });
}
/**
 * 弹出消息
 * @param {*} msg 
 */
function msg(msg) {
    layui.use('layer', function () {
        var layer = layui.layer;
        layer.msg(msg, { time: 1000, maxWidth: 200 });
    });
}
/**
 * 
 */
function getPlatePanel() {

}






































































/**
 * 显示遮罩
 * @param {*} elem 
 * @param {*} name 
 */
function setLoad(elem, name) {
    elem = $(elem);
    var w = elem.width(), h = elem.height(), t = elem.offset().top, l = elem.offset().left;
    var loadingHtml = '<div style="top:' + t + 'px;left:' + l + 'px;width:' + w + 'px;height=' + h + 'px" class="loadpanel-' + name + ' loading-panel"><img src="images/loading.gif"></div>';
    elem.append(loadingHtml);
}
/**
 * 移除遮罩
 * @param {*} name 
 */
function delLoad(name) {
    $(".loadpanel-" + name).remove();
}